package starComponent.elements;

import starComponent.E_PossibleBranches;


/**
 * @author Charles Perin
 * 11 avr. 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 */
public class LadderTickForBinaries extends LadderTick{
	
	public static final int MARGIN_UP_FOR_BINARIES = 10;
	
	public static final int TICK_WIDTH = 20;
	public static final int TICK_HEIGHT = 40;


	public LadderTickForBinaries(A_StarBranch branch, E_PossibleBranches binaryBranch, int value){
		super(branch, value, binaryBranch.getName());
	}


	@Override
	protected void calculateTickCenter(){
		xCenter = (int) ((1+value)*branch.getLength()*Math.cos(branch.getAngle())/branch.getMax()+branch.getxStart());
		yCenter = (int) (-(1+value)*branch.getLength()*Math.sin(branch.getAngle())/branch.getMax()+branch.getyStart());
	}
	
	@Override
	protected void calculateLabelPosition(){
		
		xLabel = (int) ((1+value)*branch.getLength()*Math.cos(branch.getAngle())/branch.getMax()+branch.getxStart()-labelWidth/2);
		
		if(branch.getAngle()>Math.PI)
			yLabel = (int) (-(1+value)*branch.getLength()*Math.sin(branch.getAngle())/branch.getMax()+branch.getyStart()-labelHeight);
		else
			yLabel = (int) (-(1+value)*branch.getLength()*Math.sin(branch.getAngle())/branch.getMax()+branch.getyStart()+labelHeight);
		
		xCenterLabel = xLabel + labelWidth/2;
		yCenterLabel = yLabel + labelHeight/2;
	}


	@Override
	public double getValue() {
		try {
			throw new Exception("impossible d'appeler getValue sur branche de binaires");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return -1;
	}



}


